const fs = require("fs");
const handleDir = path => {
  console.log("path:", path);
  //切分成数组
  let pathList = path.split("/");
  let pathStr = "";
  for (let item of pathList) {
    if (!item) {
      continue;
    }
    pathStr += `/${item}`;
    if (hasDir(pathStr)) {
      continue;
    }
    fs.mkdirSync(pathStr);
  }
};

const hasDir = path => {
  if (fs.existsSync(path)) {
    return true;
  } else {
    return false;
  }
};

module.exports = {
  handleDir
};
